package com.zb.order.controller;


import com.zb.entity.AccounLoginInfo;
import com.zb.result.PageUtil;
import com.zb.result.Result;
import com.zb.service.ZjWorkRemarkService;
import com.zb.utils.TokenUtil;
import com.zb.vo.WorkRemarkVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * <p>
 * 工单备注表 前端控制器
 * </p>
 *
 * @author WEN
 * @since 2024-04-02
 */
@Api(tags = "工单备注类接口")
@RestController
@RequestMapping("/ork/remark")
public class ZjWorkRemarkController {
    @Resource
    private ZjWorkRemarkService workRemarkService;

    @ApiOperation("保存工单备注")
    @PostMapping("/save")
    public Result save(HttpServletRequest request, @RequestBody @Valid WorkRemarkVo remarkVo) {
        AccounLoginInfo loginInfo = TokenUtil.getAccountLoginInfo(request);
        workRemarkService.save(loginInfo, remarkVo);
        return Result.success("添加工单备注成功");
    }

    @ApiOperation("根据工单ID获取工单备注列表")
    @PostMapping("/getWorkRemarks/{workId}")
    public Result getWorkReamrks(@PathVariable @ApiParam(value = "工单ID", required = true) Long workId, @RequestBody PageUtil pageUtil) {
        return Result.success("获取工单备注列表成功").data(workRemarkService.getWorkReamrks(workId, pageUtil));
    }

}
